<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link rel="stylesheet" href="__STATIC__/mobile/css/common.css" />
    <link rel="stylesheet" href="__STATIC__/mobile/css/contact.css" />
    <link rel="stylesheet" href="__STATIC__/mobile/css/picker.css" />
    <link rel="stylesheet" href="__STATIC__/mobile/css/layer.css" />
    <title>课程咨询</title>
</head>

<body>
    <div class="consult contact">
        <div class="consult_type">
            <div class="about_title">
                <h6>培训咨询联系方式</h6>
                <img src="__STATIC__/mobile/img/icon-red-dotted.png" alt="" />
            </div>
            <!--联系方式-->
            <div class="contact_type">
                <ul>
                    {php}$list = json_decode(setting('list'),true);{/php}
                    {foreach $list as $l}
                    <li>
                        <img src="{$l.thumb ?: ''}" alt="" />
                        <span>{$l.name ?: ''}:</span>
                        <p>{$l.value ?: ''}</p>
                    </li>
                    {/foreach}
                </ul>
                <div class="contact_btn">
                    <a href="tel:{:setting('kefu_tel')}">
                        <button>立即咨询</button>
                    </a>
                </div>
            </div>
        </div>
        <!--在线留言-->
        <div class="leave_msg">
            <div class="about_title">
                <h6>在线留言</h6>
                <img src="__STATIC__/mobile/img/icon-red-dotted.png" alt="" />
            </div>
            <form action="">
                <ul class="leave_list">
                    <li>
                        <p>您的姓名</p>
                        <input type="text" placeholder="" id="userName" name="name"/>
                    </li>
                    <li>
                        <p>性别</p>
                        <label id="sexy">
                            <input type="text" placeholder="" name="sex" value="男" onclick="$(this).blur()" readonly/>
                            <img src="__STATIC__/mobile/img/icon_down_arrow.png" alt="" />
                        </label>
                    </li>
                    <li>
                        <p>手机</p>
                        <input type="number" placeholder="" id="phone" name="phone"/>
                    </li>
                    <li>
                        <p>邮箱</p>
                        <input type="text" placeholder="" id="mail" name="mail"/>
                    </li>
                    <li>
                        <p>职业</p>
                        <input type="text" placeholder="" id="collect" name="collect"/>
                    </li>
                    <li>
                        <p>单位</p>
                        <input type="text" placeholder="" id="company" name="company"/>
                    </li>
                    <li>
                        <p>留言</p>
                        <textarea name="content" id=""></textarea>
                    </li>
                </ul>
                <div class="contact_btn" id="confirm">
                    <a href="javascript:;">
                        <button type="button">提交</button>
                    </a>
                </div>
            </form>
        </div>
    </div>

    <script src="__STATIC__/mobile/js/rem.js"></script>
    <script src="__STATIC__/mobile/js/jquery-3.3.1.min.js"></script>
    <script src="__STATIC__/mobile/js/picker.min.js"></script>
    <script src="__STATIC__/mobile/js/layer.js"></script>
    <script>
        //性别
        var data2 = [{
            text: '男',
            value: 1
        }, {
            text: '女',
            value: 2
        }];
        var identifyE2 = document.getElementById('sexy');
        var identify = new Picker({
            data: [data2]
        });
        identify.on('picker.select', function(selectedVal, selectedIndex) {
            $('#sexy').children('input').val(data2[selectedIndex[0]].text)
        });
        identifyE2.addEventListener('click', function() {
            identify.show()
        });
        //提交
        $('#confirm').on('click', function() {
            var name = $('[name="name"]').val();
            var sex = $('[name="sex"]').val();
            var phone = $('[name="phone"]').val();
            var mail = $('[name="mail"]').val();
            var collect = $('[name="collect"]').val();
            var company = $('[name="company"]').val();
            var content = $('[name="content"]').val();

            if ($('#userName').val() == '') {
                layer.open({
                    content: "请输入您的姓名",
                    skin: "msg",
                    time: 2,
                })
                return false
            }
            if ($('#sexy').children('input').val() == '') {
                layer.open({
                    content: "请选择您的性别",
                    skin: "msg",
                    time: 2,
                })
                return false
            }
            if ($('#phone').val() == '') {
                layer.open({
                    content: "请输入您的手机",
                    skin: "msg",
                    time: 2,
                })
                return false
            }
            if ($('#mail').val() == '') {
                layer.open({
                    content: "请输入您的邮箱",
                    skin: "msg",
                    time: 2,
                })
                return false
            }
            if ($('#collect').val() == '') {
                layer.open({
                    content: "请输入您的职业",
                    skin: "msg",
                    time: 2,
                })
                return false
            }
            if ($('#company').val() == '') {
                layer.open({
                    content: "请输入您的单位",
                    skin: "msg",
                    time: 2,
                })
                return false
            }
            $.ajax({
                url:'{:url("/m/apply2")}',
                type:'post',
                data:{name:name,sex:sex,phone:phone,mail:mail,collect:collect,company:company,content:content,lesson_id:"{$lesson_id ?: ''}"},
                success:function (res) {
                    if(res.code==1){
                        layer.open({
                            content: "提交成功",
                            skin: "msg",
                            time: 2,
                            end:function () {
                                location.reload();
                            }
                        })
                    }else if(res.code=='busy'){
                        layer.open({
                            content: "您操作太频繁啦，稍后再来吧！",
                            skin: "msg",
                            time: 2,
                        })
                    }else {
                        layer.open({
                            content: "请输入正确信息",
                            skin: "msg",
                            time: 2,
                        })
                    }
                }
            })
        })
    </script>
</body>

</html>